package model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import dao.GetCnn;
import dao.common;

public class ThuonghieuModel {
	public String getOptions(boolean isSearch, boolean isRequired, String selectedValue) {   

	    String sOptions = "";   
	    String sSel = "";   

	    if (isSearch) {   
	        sOptions += "<option value=\"\">All</option>";   
	    } else {   
	        if (!isRequired) {   
	            sOptions += "<option value=\"\"></option>";   
	        }   
	    }   
	    try {   
	    	String select = "select * from THUONGHIEU";
			Connection cnn = GetCnn.getCnn();
			Statement stat = cnn.createStatement();
			ResultSet rs = stat.executeQuery(select); 
	        while (rs.next()) {   
	            String id =common.toHTML(rs.getString(1));
	            String val = common.toHTML(rs.getString(2));   
	            if (id.compareTo(selectedValue) == 0) {   
	                sSel = "SELECTED";   
	            } else {   
	                sSel = "";   
	            }   
	            sOptions += "<option value=\"" + id + "\" " + sSel + ">" + val   
	                    + "</option>";   
	        }   
	        rs.close();   
	        stat.close();   
	    } catch (Exception e) {   
	    }   
	    return sOptions;   
	}

}
